//
//  MCReceivedHongBaoTableViewCell.m
//  XDYL
//
//  Created by MC on 2018/3/20.
//  Copyright © 2018年 TLYL01. All rights reserved.
//

#import "MCReceivedHongBaoTableViewCell.h"
#import "MCDataTool.h"
#import "MCMathUnits.h"

@interface MCReceivedHongBaoTableViewCell ()


//1
@property (nonatomic,strong)UILabel * lab1;//左上
//2
@property (nonatomic,strong)UILabel * lab2;//左下


//3
@property (nonatomic,strong)UILabel * lab3;//右上
//4
@property (nonatomic,strong)UILabel * lab4;//右下


@end

@implementation MCReceivedHongBaoTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self initView];
    }
    return self;
}

- (void)initView{
    
    self.backgroundColor=[UIColor whiteColor];

    
    /*
     * logo
     */
    UIImageView * arrow=[[UIImageView alloc]init];
    [self addSubview:arrow];
    arrow.image=[UIImage imageNamed:@"person-icon-more"];
    arrow.userInteractionEnabled=NO;
    [arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-10);
        make.width.mas_equalTo(9);
        make.height.mas_equalTo(16);
        make.centerY.equalTo(self.mas_centerY);
    }];
    
    /*
     * 下划线
     */
    UIView * line =[[UIView alloc]init];
    line.backgroundColor=RGB(213,213,213);
    [self  addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-10);
        make.left.equalTo(self.mas_left).offset(10);
        make.bottom.equalTo(self.mas_bottom).offset(-1);
        make.height.mas_equalTo(0.5);
        
    }];
    
    
    CGFloat W = (G_SCREENWIDTH-50)/2.0;

    UILabel * lab1=[self GetAdaptiveLable:CGRectMake(15, 10, W, 25) AndText:@"加载中" andFont:14 andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [self addSubview:lab1];
    _lab1=lab1;
    
    
    
    //lab2
    UILabel * lab2=[self GetAdaptiveLable:CGRectMake(15, 35, W, 25) AndText:@"加载中" andFont:10 andTextColor:RGB(136,136,136) andTextAlignment:NSTextAlignmentLeft];
    [self addSubview:lab2];
    _lab2=lab2;

    
    
    //lab3
    UILabel * lab3=[self GetAdaptiveLable:CGRectMake((G_SCREENWIDTH-60-20)/2.0, 10, W, 25) AndText:@"加载中" andFont:14 andTextColor:RGB(255,69,69) andTextAlignment:NSTextAlignmentRight];
    [self addSubview:lab3];
    _lab3=lab3;
    
    //lab4
    UILabel * lab4=[self GetAdaptiveLable:CGRectMake((G_SCREENWIDTH-60-20)/2.0, 35, W, 25) AndText:@"加载中" andFont:10 andTextColor:RGB(136,136,136) andTextAlignment:NSTextAlignmentRight];
    [self addSubview:lab4];
    _lab4=lab4;
    

}


-(UILabel *)GetAdaptiveLable:(CGRect)rect AndText:(NSString *)contentStr andFont:(CGFloat)font  andTextColor:(UIColor *)textColor andTextAlignment:(NSTextAlignment)textAlignment;
{
    
    
    UILabel *contentLbl = [[UILabel alloc] initWithFrame:rect];
    contentLbl.text = contentStr;
    contentLbl.textAlignment = textAlignment;
    contentLbl.numberOfLines = 0;
    contentLbl.font = [UIFont systemFontOfSize:font];
    contentLbl.textColor=textColor;
    contentLbl.clipsToBounds=YES;
    
    return contentLbl;
}


+(CGFloat)computeHeight:(id)info{
    
    return 65;
}

-(void)setDataSource:(MCRecordsModel *)dataSource{
    
    _dataSource=dataSource;
    
    _lab1.text=[NSString stringWithFormat:@"%@",dataSource.UserName];
    _lab2.text=dataSource.OpenTime;//@"20170815 09:03:06";
    NSString * Amount= [NSString stringWithFormat:@"%@",dataSource.Amount];
    _lab3.text=[NSString stringWithFormat:@"%@元",GetTwoDigitRealSNum(Amount)];//@"195.65元";
    //2是拼手气 1是普通
    if ([[NSString stringWithFormat:@"%@",dataSource.Mode] isEqualToString:@"1"]) {
        _lab4.text=@"普通红包";
    }else{
        _lab4.text=@"拼手气红包";
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end



















